/*
 * @Author: lsjweiyi
 * @Date: 2023-02-10 20:44:01
 * @LastEditors: lsjweiyi
 * @LastEditTime: 2023-07-29 22:29:36
 * @Description: 路由初始化
 * Copyright (c) 2023 by lsjweiyi, All Rights Reserved.
 */
package router

import (
	"src/middleware"

	"github.com/gin-gonic/gin"
)

func InitRouter() *gin.Engine {
	// router := ReleaseRouter()
	router:=gin.Default()
	// 设置可信任的代理服务器列表,gin (2021-11-24发布的v1.7.7版本之后出的新功能)
	_ = router.SetTrustedProxies(nil)

	// 允许跨域和防止一些常见网络攻击，不需要可以屏蔽
	router.Use(middleware.Options()).Use(middleware.Secure()).Use(middleware.LogHandler()).Use(middleware.LimitHandler())

	// 静态资源代理
	router.Static("/assets", "./dist/assets")
	router.StaticFile("/", "./dist/index.html")

	return router
}
